<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>用户数据</title>
		<link rel="stylesheet" href="css/_all-skins.min.css" />
		<link rel="stylesheet" href="css/AdminLTE.min.css" />
		<link rel="stylesheet" href="css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/daterangepicker.css" />
		<link rel="stylesheet" href="css/select2.min.css" />
		<link rel="stylesheet" href="css/font-awesome.min.css" />
		<link rel="stylesheet" href="css/echart.css" />
		<link rel="stylesheet" type="text/css" href="css/layer.css"/>
		<link rel="stylesheet" href="css/order_data.css" />
	</head>
	<style>
		.vip_action{
			height: 100px;
			margin-top: 20px;
		}
		.vip_action table{
			width: 100%;
			border-collapse: collapse;
		}
		.vip_action table th{
			background:#70dada ;
			color: white;
		}
		.vip_action table td,.vip_action table th{
			height: 35px;
			border: solid 1px white;
			font-weight: normal;
			text-align: center;
			font-size: 12px;
			background:#70dada ;
			color: white;
			
		}
		.lines_text{
			padding-top: 80px;
		}
		.user_tip,.vip_tip{
			text-align: center;
		}
		.user_tip p,.vip_tip p{
			text-align: left;
			display: inline-block;
		}
	</style>
	<body class="hold-transition skin-blue sidebar-mini fixed">
<div class="wrapper">

   <header class="main-header">
    <!-- Logo -->
    <a href="index2.html" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
   
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>衣当先</b>CRM</span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>

      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <li class="dropdown user user-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            	
              <img src="img/user2-160x160.jpg" class="user-image" alt="User Image">
              <span class="hidden-xs  manger-name">Amy</span>
               
            	 <span class="change_password" style="font-size: 12px;margin-left: 40px;">修改密码</span>
            	 <span class="exit_login" style="font-size: 12px;">退出登录</span>
            </a>
            
          </li>
        </ul>
      </div>
    </nav>
  </header>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar user panel -->
      <div class="user-panel">
        <div class="pull-left image">
          <img src="img/user2-160x160.jpg" class="img-circle">
        </div>
        <div class="pull-left info">
          <p class="manger-name">Amy</p>
          <a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
        </div>
      </div>
      <!-- search form -->
      <form action="#" method="get" class="sidebar-form">
        <div class="input-group">
          <input type="text" name="q" class="form-control" placeholder="Search...">
          <span class="input-group-btn">
                <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
        </div>
      </form>
      <!-- /.search form -->
      <!-- sidebar menu: : style can be found in sidebar.less -->
      <ul class="sidebar-menu" data-widget="tree">
        <li class="header">功能目录</li>
        
        <li class=" treeview">
          <a href="#">
            <i class="fa fa-dashboard"></i> <span>系统首页</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li class=""><a href="index.html"><i class="fa fa-circle-o"></i> 首页总览</a></li>
            <li><a href="login_log.html"><i class="fa fa-circle-o"></i> 登录日志</a></li>
              <li><a href="id_manager.html"><i class="fa fa-circle-o"></i> 账号管理</a></li>
          </ul>
        </li>
      
        <li class="treeview">
          <a href="#">
            <i class="fa fa-laptop"></i>
            <span>商品管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
           <ul class="treeview-menu">
            <li><a href="product_list.html"><i class="fa fa-circle-o"></i> 商品列表</a></li>
            <li><a href="new_product.html"><i class="fa fa-circle-o"></i> 新增商品</a></li>
            <li><a href="product_kind.html"><i class="fa fa-circle-o"></i> 商品分类</a></li>
            <li><a href="product_confirm.html"><i class="fa fa-circle-o"></i> 商品审核</a></li>
             <li><a href="product_income.html"><i class="fa fa-circle-o"></i> 商品回收</a></li>
          </ul>
        </li>

        <li class="treeview">
          <a href="#">
            <i class="fa fa-edit"></i> <span>订单管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="hire_order.html"><i class="fa fa-circle-o"></i> 租赁订单</a></li>
            <li><a href="pay_order.html"><i class="fa fa-circle-o"></i> 支付订单</a></li>
            <li><a href="operate_log.html"><i class="fa fa-circle-o"></i> 订单日志</a></li>
          </ul>
        </li>          
        <li class="treeview">
          <a href="#">
            <i class="fa fa-pie-chart"></i>
            <span>用户管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="user_list.html"><i class="fa fa-circle-o"></i> 用户列表</a></li>
            <li><a href="discounts.html"><i class="fa fa-circle-o"></i> 优惠卷中心</a></li>
          </ul>
        </li>
        <li class="treeview active">
          <a href="#">
            <i class="fa fa-pie-chart"></i>
            <span>数据管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="all_data.html"><i class="fa fa-circle-o"></i> 数据日报</a></li>
            <li><a href="product_data.html"><i class="fa fa-circle-o"></i> 商品数据</a></li>
            <li><a href="order_data.html"><i class="fa fa-circle-o"></i> 订单数据</a></li>
            <li class="active"><a href="user_data.html"><i class="fa fa-circle-o"></i> 用户数据</a></li>
           <li><a href="income_data.html"><i class="fa fa-circle-o"></i> 收入数据</a></li>
          </ul>
        </li> 
        <li>
          <a href="advice.html">
            <i class="fa fa-files-o"></i> <span>反馈建议</span>
          </a>
        </li>
         <li>
          <a href="w_internet.html">
            <i class="fa fa-book"></i> <span>物联网订单</span>
          </a>
        </li>
      </ul>
    </section>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    

    <!-- Main content -->
           
    
    <section class="content" >
       <div class="row">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10" style="padding: 0;">
       	 	
       	 	<div class="order_status">
       	 			<div>
       	 				<label>0</label><br />
       	 				<span>新注册用户</span>
       	 			</div>
       	 			
       	 			<div>
       	 				<label>0</label><br />
       	 				<span>总会员用户</span>
       	 			</div>
       	 			
       	 			<div>
       	 				<label>0</label><br />
       	 				<span>活跃用户</span>
       	 			</div>
       	 			
       	 			<div>
       	 				<label>0</label><br />
       	 				<span>会员占比</span>
       	 			</div>
       	 			<div>
       	 				<label>0</label><br />
       	 				<span>新增注册</span>
       	 			</div>
       	 	</div>
       	 </div>
       </div>
	   <div class="row">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10 box1">
       	 	<div class="box_title">
       	 		<h4>用户增长曲线</h4>
       	 		<input type="text" placeholder="请输入时间范围" class="date_pick form-control " id="reservation" style="width: 200px;">
       	 		<input type="button" class="btn btn-default user_search" value="筛选"/>
       	 	</div>
       	 	<div class=" row box1_lines">
       	 		<div class="col-lg-9 col-md-12 lines_item" id="my_chart2">
       	 		</div>
       	 		<div class="col-lg-3 col-md-12 lines_item lines_text user_tip">
       	 			
       	 		</div>
       	 	</div>
       	 </div>
       </div>
       <div class="row" style="margin-top: 20px;">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10 box1">
       	 	<div class="box_title">
       	 		<h4>会员增长曲线</h4>
       	 		<input type="text" placeholder="请输入时间范围" class="date_pick form-control " id="reservation2" style="width: 200px;">
       	 		<input type="button" class="btn btn-default vip_search" value="筛选"/>
       	 	</div>
       	 	<div class=" row box1_lines">
       	 		<div class="col-lg-9 col-md-12 lines_item" id="my_chart">
       	 		</div>
       	 		<div class="col-lg-3 col-md-12 lines_item lines_text vip_tip">
       	 		</div>
       	 	</div>
       	 </div>
       </div>
        <div class="row" style="margin-top: 20px;">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10 box1">
       	 	<div class="box_title">
       	 		<h4>会员行为图表</h4>
       	 		<select placeholder="请选择时间范围" class="select2 form-control month_pick"  style="width: 200px;">
       	 			<option value="1月">1月</option>
       	 			<option value="2月">2月</option>
       	 			<option value="3月">3月</option>
       	 			<option value="4月">4月</option>
       	 			<option value="5月">5月</option>
       	 			<option value="6月">6月</option>
       	 			<option value="7月">7月</option>
       	 			<option value="8月">8月</option>
       	 			<option value="9月">9月</option>
       	 			<option value="10月">10月</option>
       	 			<option value="11月">11月</option>
       	 			<option value="12月">12月</option>
       	 		</select>
       	 		<input type="button" class="btn btn-default action_search" value="筛选"/>
       	 	</div>
       	 	<div class="box1_lines row">
       	 		
       	 		<div class="col-lg-12 vip_action">
       	 			<table>
       	 				<thead>
       	 					<tr>
       	 						<th>月租赁订单</th>
       	 						<th>每单租赁时长</th>
       	 						<th>租赁场景 no.1</th>
       	 						<th>租赁场景no.2</th>
       	 						<th>租赁场景no.3</th>
       	 						<th>单月会员</th>
       	 						<th>连续包月</th>
       	 					</tr>
       	 				</thead>
       	 				<tbody class="table_data">
       	 					
       	 				</tbody>
       	 			</table>
       	 		</div>
       	 		<div>
       	 			<div class="col-lg-6 col-md-12 lines_item" id="pie_chart1"></div>
       	 			<div class="col-lg-6 col-md-12 lines_item" id="pie_chart2"></div>
       	 			<div class="col-lg-6 col-md-12 lines_item" id="pie_chart3"></div>
       	 			<div class="col-lg-6 col-md-12 lines_item" id="pie_chart4"></div>
       	 		</div>
       	 		
       	 	</div>
       	 </div>
       </div>
    </section>
    <!-- /.content -->
  </div>
   
  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <div class="pull-right hidden-xs">
      <b>Version</b> 2.0.0
    </div>
    <strong>Copyright &copy; 2017-2018 西安寒武纪信息科技有限公司.</strong> All rights
    reserved.
  </footer>
</div>
<script src="js/jquery.min.js"></script>



<script src="js/adminlte.min.js"></script>
<script src="js/layer.js"></script>
<script type="text/javascript" src="js/echarts-all.js" ></script>
<script src="js/macarons.js"></script>
<script type="text/javascript" src="js/moment.min.js" ></script>
<script src="js/daterangepicker.js"></script>
<script src="js/select2.full.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jq.cookie.js"></script>
<script src="js/change_password.js"></script>
<script>
	$(document).ready(function(){
	
	 "use strict"; 
	 $('.select2').select2();
	  $('#reservation').daterangepicker({
	  	startDate:'2018-11-01',
	  	locale:{format:'YYYY-MM-DD'}
	  });
	   $('#reservation2').daterangepicker({
	   	startDate:'2018-11-01',
	  	locale:{format:'YYYY-MM-DD'}
	  });
	  getData();
	  
	  $('.user_search').click(function(){
	  	    var data_rang = $('#reservation').val();//时间范围
            var start = data_rang.split(' -')[0];
			var end = data_rang.split('- ')[1];
		  	   $.ajax({
		  	   	type:"get",
		  	   	url:"https://www.retux.cn/MgUserLogSearch1",
		  	   	async:true,
		  	   	data:{
		  	   		start:start,
		  	   		end:end
		  	   	},
		  	   	success:function(data){
		  	   		if(data.length==0){
				  			layer.msg('暂无数据');
				  		}else{
				  			userLine(data)
				  		}
		  	   		
		  	   	}
		  	   });
	  })
	   $('.vip_search').click(function(){
	   	var data_rang = $('#reservation2').val();//时间范围
            var start = data_rang.split(' -')[0];
			var end = data_rang.split('- ')[1];
		  	   $.ajax({
		  	   	type:"get",
		  	   	url:"https://www.retux.cn/MgUserLogSearch2",
		  	   	async:true,
		  	   	data:{
		  	   		start:start,
		  	   		end:end
		  	   	},
		  	   	success:function(data){
		  	   		if(data.length==0){
				  			layer.msg('暂无数据');
				  		}else{
				  			vipLine(data);
				  		}
		  	   		
		  	   	}
		  	   });
	  })
	    $('.action_search').click(function(){
	    	var Month = $('.month_pick').select2('val');
		  	   $.ajax({
		  	   	type:"get",
		  	   	url:"https://www.retux.cn/MgUserLogSearch3",
		  	   	async:true,
		  	   	data:{
		  	   		Month:Month
		  	   	},
		  	   	success:function(data){
		  	   		
		  	   		barView(data[0],data[1])
		  	   	}
		  	   });
	  })
     function getData(){
     	$.ajax({
     		type:"get",
     		url:"https://www.retux.cn/MgUserLog",
     		async:true,
     		success:function(data){
     			dataView(data);
     		}
     	});
     }
     function dataView(data){
     	//基础数据
     	var labelDom = $('.order_status').find("label");
     	$.each(data[0], function(i,v) {
     		labelDom.eq(i).text(v)
     	});
     	//用户增长曲线
     	
     	
     	userLine(data[1]);
     	//VIP增长曲线
     
     	vipLine(data[2]);
     	
     	//行为图标
     	barView(data[3],data[4])
     	
     }
     
    
     function vipLine(data){
     	 var myChart = echarts.init(document.getElementById('my_chart'),'macarons');
     	 	var vipData_X = [];
	     	var vipData_Y = [];
	     	$.each(data[0], function(k,v) {
	     		vipData_X.push(k);
	     		vipData_Y.push(v)
	     		
	     	});
	     	$('.vip_tip').html("")
	     	var vipTip = `
     					<p><span>${data[1]}</span>天内共新增<span>${data[2]}</span>会员</p><br/>
       	 			    <p><span>${data[3]}</span>新增<span>${data[4]}</span>会员为所选时间区域内高峰</p>
     	              `;
     	$('.vip_tip').append(vipTip)
     	   myChart.setOption({
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			        data:['会员增长']
			    },
			    toolbox: {
			        show : true,
			        feature : {
			            magicType : {show: true, type: ['line', 'bar']},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    xAxis : [
			        {
			            data : vipData_X
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'会员增长',
			            type:'line',
			            data: vipData_Y
			            
			        }
			    ]
			    
			});
     }
     function userLine(data){
     	var myChart2 = echarts.init(document.getElementById('my_chart2'),'macarons');
     	var userData_X = [];
     	var userData_Y = [];
     	$.each(data[0], function(k,v) {
     		userData_X.push(k);
     		userData_Y.push(v)
     		
     	});
     	$('.user_tip').html("")
     	var userTip = `
     					<p><span>${data[1]}</span>天内共新增<span>${data[2]}</span>用户</p><br/>
       	 			    <p><span>${data[3]}</span>新增<span>${data[4]}</span>用户为所选时间区域内高峰</p>
     	`;
     	$('.user_tip').append(userTip)
     	myChart2.setOption({
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			        data:['新增注册']
			    },
			    toolbox: {
			        show : true,
			        feature : {
			            magicType : {show: true, type: ['line', 'bar']},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    xAxis : [
			        {
			            data :userData_X
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [{
			            name:'新增注册',
			            type:'line',
			            data:userData_Y
			            
			        }
			    ]
			    
			});
     	
     }
     function barView(data_1,data_2){
     	$('.table_data').html('');
     	
	     	var vipAction = `<tr>
	       	 						<td>${data_1[0]}</td>
	       	 						<td>${data_1[1]}</td>
	       	 						<td>${data_1[2][0][0]}</td>
	       	 						<td>${data_1[2][1][0]}</td>
	       	 						<td>${data_1[2][2][0]}</td>
	       	 						<td>${data_1[3]}</td>
	       	 						<td>${data_1[4]}</td>
	       	 					</tr>`;
	     	
	     	$('.table_data').append(vipAction);
	     	
	     	pie_view(data_1[2]);
	     	
	     	var par2Data = data_1[3].split("%")[0];
	     	var par2Data2 = data_1[4].split("%")[0];
	     	pie_view2([par2Data,par2Data2]);
	     	
	     	var cityData= [];
	     	var cityLegent = [];
	     	$.each(data_2[0], function(k,v) {
	     		var cityJson = {};
	     		cityJson["value"] = v;
	     		cityJson["name"] = k;
	     		cityLegent.push(k)
	     		cityData.push(cityJson)
	     		
	     	});
	     	pie_view3('pie_chart3',cityData,cityLegent);
	     	
	     	var sizeData = [];
	     	var sizeLegent = [];
	     	$.each(data_2[1], function(k,v) {
	     		var sizeJson = {};
	     		sizeJson["value"] = v;
	     		sizeJson["name"] = k;
	     		sizeLegent.push(k);
	     		sizeData.push(sizeJson)
	     		
	     	});
	     	pie_view3('pie_chart4',sizeData,sizeLegent);
     }
     
   
     
   	 	
function pie_view(data){
	console.log(data)
	var pieChart1 = echarts.init(document.getElementById('pie_chart1'),'macarons'); 
		 pieChart1.setOption({
				    title : {
				        text: '场景租赁对比',
				        x:'center'
				    },
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c} ({d}%)"
				    },
				    legend: {
				        orient : 'vertical',
				        x : 'left',
				        data:['日常休闲','婚礼宴会','商务职场']
				    },
				    toolbox: {
				        show : true,
				        feature : {
				            saveAsImage : {show: true}
				        }
				    },
				    calculable : true,
				    series : [ 
				        {
				            name:'',
				            type:'pie',
				            radius : '55%',
				            center: ['50%', '60%'],
				            data:[
				                {value:data[0][1], name:data[0][0]},
				                {value:data[1][1], name:data[1][0]},
				                {value:data[2][1], name:data[2][0]}
				            ]
				        }
				    ]
				});
          }

   	 function pie_view2(data){
   	 	  var pieChart2 = echarts.init(document.getElementById('pie_chart2'),'macarons'); 
		 pieChart2.setOption({
				    title : {
				        text: '包月方式',
				        x:'center'
				    },
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c} ({d}%)"
				    },
				    legend: {
				        orient : 'vertical',
				        x : 'left',
				        data:['单月会员','连续包月']
				    },
				    toolbox: {
				        show : true,
				        feature : {
				            saveAsImage : {show: true}
				        }
				    },
				    calculable : true,
				    series : [
				        {
				            name:'',
				            type:'pie',
				            radius : '55%',
				            center: ['50%', '60%'],
				            data:[
				                {value:data[0], name:"单月会员"},
				                {value:data[1], name:"连续包月"}
				            ]
				        }
				    ]
				});
          }
    function pie_view3(dom,data,legent){
    	 var pieDom = echarts.init(document.getElementById(dom),'macarons'); 
		 pieDom.setOption({
				    title : {
				        text: '地域分布',
				        x:'center'
				    },
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c} ({d}%)"
				    },
				    legend: {
				        orient : 'vertical',
				        x : 'left',
				        data:legent
				    },
				    toolbox: {
				        show : true,
				        feature : {
				            saveAsImage : {show: true}
				        }
				    },
				    calculable : true,
				    series : [
				        {
				            name:'',
				            type:'pie',
				            radius : '55%',
				            center: ['50%', '60%'],
				            data:data
				        }
				    ]
				});
          }             
	})
	
</script>	
</body>
</html>
